package jdk7demo1;

import java.util.Random;

public class Test1 {
    public static void main(String[] args) {
        Random r = new Random();
        Date d1 = new Date(Math.abs(r.nextInt()));
        Date d2 = new Date(Math.abs(r.nextInt()));
        System.out.println(d1);
        System.out.println(d2);
        long time1 = d1.getTime();
        long time2 = d2.getTime();
        if (time1 > time2) {
            System.out.println("d1>d2");
        } else if (time1 < time2) {
            System.out.println("d1<d2");
        } else {
            System.out.println("d1=d2");
        }
        extracted();
    }

    private static void extracted() {
        Date d1 = new Date(0L);
        long time = d1.getTime();
        time += 1000L * 60 * 60 * 24 * 365;
        d1.setTime(time);
        System.out.println(d1);
    }
}

class Date {
    private long time;

    public Date() {
    }

    public Date(long time) {
        this.time = time;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    @Override
    public String toString() {
        return "Date{" + "time=" + time + '}';
    }

}
